<?php
class HomeController extends AppController
{
	public $name = 'Home';
    public $uses = array('News', 'Case', 'Service', 'Banner');

	public function Index()
	{
        $news = $this->News->find('all', array(
            'conditions' => array(
                'is_deleted' => 0
            ),
            'order' => array(
                'News.id' => 'desc'
            ),
            'limit' => 3
        ));

        $cases = $this->Case->find('all', array(
            'conditions' => array(
                'is_deleted' => 0
            ),
            'order' => array(
                'priority' => 'desc',
                'id' => 'desc'
            ),
            'limit' => 4
        ));

        $this->Service->contain();
        $services = $this->Service->find('all', array(
            'conditions' => array(
                'is_deleted' => 0,
                'in_home' => 'Yes',
            ),
        ));

        $banners = $this->Banner->find('all', array(
            'conditions' => array(
                'is_deleted' => 0,
            ),
            'order' => array(
                'priority' => 'desc'
            )
        ));

        $this->set('bannerList', $banners);
        $this->set('newsList', $news);
        $this->set('serviceList', $services);
        $this->set('caseList', $cases);
	}
}
